package edu.snake.implement.view;

import edu.snake.core.model.Character;
import edu.snake.core.model.Position;
import edu.snake.implement.ConfigConstant;

import javax.swing.ImageIcon;
import java.awt.Graphics;
import java.awt.Image;


public class FrogRender {

    Image image;
    Image image02;


    public FrogRender() {
        this.image = new ImageIcon(this.getClass().getResource("frog_1.png")).getImage();
        this.image02 = new ImageIcon(this.getClass().getResource("frog_2.png")).getImage();
    }


    public void render(Position position, Character character, Graphics g) {
        if (character.getScore() == 1) {
            draw(position, image, g);
        } else {
            draw(position, image02, g);
        }
    }

    private void draw(Position position, Image image, Graphics g) {
        int scale = ConfigConstant.cellSizePixel;
        g.drawImage(image
                , position.getWidth() * scale
                , position.getHeight() * scale
                , scale
                , scale
                , null);
    }
}